package com.settlement.system.service.impl;

import com.settlement.system.mapper.ItemMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.Item;
import com.settlement.system.service.IItemService;
import org.springframework.stereotype.Service;
import com.settlement.system.mapper.BaseMapper;
import jakarta.annotation.Resource;

/**
 * 商品资料表 服务实现类
 * @author Ximi
 * @since 2020-04-15
 */
@Service
public class ItemServiceImpl extends BaseServiceImpl implements IItemService {

    @Resource
    private ItemMapper itemMapper;

    @Override
    public BaseMapper init() {
        return itemMapper;
    }

    /**
     * 获取Item(通过关联item_sku)
     * @param brandUnitNo 品牌部编码
     * @param barcode 条码
     * @return
     * @throws ServiceException
     */
    @Override
    public Item getItemJoinSku(String brandUnitNo, String barcode) throws ServiceException {
        try {
            return itemMapper.getItemJoinSku(brandUnitNo, barcode);
        } catch (Exception e) {
            throw new ServiceException("获取Item(通过关联item_sku)异常",e);
        }
    }

    /**
     * 获取Item(通过关联item_barcode_sku)
     * @param brandUnitNo 品牌部编码
     * @param barcode 条码
     * @return
     * @throws ServiceException
     */
    @Override
    public Item getItemJoinBarcodeSku(String brandUnitNo, String barcode) throws ServiceException {
        try {
            return itemMapper.getItemJoinBarcodeSku(brandUnitNo, barcode);
        } catch (Exception e) {
            throw new ServiceException("获取Item(通过关联item_barcode_sku)",e);
        }
    }

}

